@ashishjain15491/tapcheck 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,48 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.3 (2026-11-26)
4
+
5
+ - **Hash-routed apps.** A screen at `/#scanner` or `/#/orders` is its own page: it is loaded afresh (so it has an
6
+ HTTP status, not 0), the crawl keeps it apart from `/` and follows `#/route` links, and `interact` and `audit` treat
7
+ a new hash as another screen.
8
+ - **Sign-in through Google, Discord and the like.** `login: manual` waits until the browser is back on the app's own
9
+ site, so a provider's consent page no longer counts as signed in.
10
+ - **Sessions that end without a redirect.** `sides.<name>.signedIn` is a selector on every signed-in page; a page
11
+ without it stops the side as "session expired", for apps that show their sign-in form at the same address. The saved
12
+ session is written again as each part ends, so sign-ins whose tokens change on every refresh stay good across parts
13
+ and runs.
14
+ - **interact** never clicks a dark mode, light mode or theme control, which would change the account's settings.
15
+ - **context and expect.** `context:` says what kind of product it is (a dense trading tool, a clinical system) and goes
16
+ to Jev with every question, so screens are judged against what its users expect. `expect:` lists findings that are
17
+ right for the product, as `{ match, why }` on `<suite>: <check> @ <where>`: a matching fail or warn is recorded as
18
+ info with the reason, so it stays in the report without failing the run.
19
+ - **Marked screenshots.** `MARK=1` (or `marks: true`) puts a marked screenshot first in a failing or warning finding's
20
+ evidence: the screen as it was measured, a banner above it saying the check, and a box, a number and a note on each
21
+ element, placed so that none covers another. `audit`, `a11y`, `crawl` and `interact` mark the elements they found;
22
+ what Jev judged, and a failed flow step, get the banner alone. Off by default, and nothing changes without it.
23
+ - **t.mark.** `t.mark(check, status, marks, detail?)` records a finding a flow decided, with a marked screenshot of
24
+ the current page: red for a bug, green for a pass, blue for a setting, amber for a question. It needs no Jev.
25
+ - **Verify a release or a pull request.** The new `tapcheck-verify` skill splits a release note, a pull request or a
26
+ range of commits into items and writes a flow for each. A flow says which item it checks with `item:`, or
27
+ `t.untested(why)` when it can't be checked now; `ONLY=verify` runs just those flows, and the report opens with
28
+ "Release verification": the count, the failed items with their steps and screenshots, the passed table, the
29
+ questions and what wasn't tested. `verify` is a tag now, so no side can be called that.
30
+
31
+ ## 0.1.2 (2026-11-25)
32
+
33
+ - **GitHub Marketplace.** The Action is named "tapcheck audit", since the Marketplace needs a name no GitHub account
34
+ uses. It is still used as `ashishjain15491/tapcheck@<tag>`.
35
+ - **Escaping fixes** (from CodeQL). A backslash in a coverage row no longer breaks its `COVERAGE.md` table cell, and a
36
+ `login.form` field name with a backslash in it finds its field.
37
+
3
38
  ## 0.1.1 (2026-11-25)
4
39
 
5
40
  No change to what tapcheck checks or how it runs.
6
41
 
7
42
  - **README and logo.** A shorter README in the usual layout, with the tapcheck logo (light and dark), a report
8
- screenshot and badges; the logo kit is in `assets/`. The Codex plugin and the Action use the brand colour.
43
+ screenshot and badges, and setup steps for each way to run it: writing `tapcheck.yml`, the Jev key, sign-in
44
+ variables, then the plugin, npm, the Action and Docker. The logo kit and the social preview are in `assets/`; the
45
+ Codex plugin and the Action use the brand colour.
9
46
  - **GitHub Marketplace.** The Action's description fits the Marketplace's 125 characters.
10
47
  - **Action.** It runs on the current `actions/setup-node` and `actions/upload-artifact` (v7).
11
48
  - **Releases from GitHub.** `.github/workflows/publish.yml` publishes to npm when a release is published, through npm
@@ -14,7 +51,8 @@ No change to what tapcheck checks or how it runs.
14
51
 
15
52
  ## 0.1.0 (2026-11-25)
16
53
 
17
- The first release: on npm as `@ashishjain15491/tapcheck` (the CLI is still `tapcheck`), and as the GitHub Action `ashishjain15491/tapcheck@v0.1.0`.
54
+ The first release: on npm as `@ashishjain15491/tapcheck` (the CLI is still `tapcheck`), and as the GitHub Action
55
+ `ashishjain15491/tapcheck@v0.1.0`.
18
56
 
19
57
  - **Core harness.** One `tapcheck.yml` describes the app: how to start, stop and reset it, its sides and how each
20
58
  signs in (`none`, `manual`, `form` with optional TOTP, `command`), screens, tasks and viewports. `$NAME` values come
@@ -61,9 +99,10 @@ The first release: on npm as `@ashishjain15491/tapcheck` (the CLI is still `tapc
61
99
  only pages it actually crawled count toward `crawl.max` (a long route list used to crowd the links out). The
62
100
  signed-out check follows redirects, so `/` → `/admin` → `/login` counts as refused. A CSRF token cookie
63
101
  (`XSRF-TOKEN`, `csrftoken`) may be readable by script. The CSRF probe goes to the sides that sign in (every side
64
- when none does), and a side can have its own `csrf`. Flows get `t.note(name, detail, 'warn' | 'info')` and a `timeout` (default 3600 s), so a flow that hangs fails instead
65
- of stalling the run. A step that returns `{ warn: '…' }` is recorded as a warning, and `t.mail` has `count()` and
66
- `all()`, with each message's `id` and `headers` (for checks such as List-Unsubscribe on every email of a send).
102
+ when none does), and a side can have its own `csrf`. Flows get `t.note(name, detail, 'warn' | 'info')` and a
103
+ `timeout` (default 3600 s), so a flow that hangs fails instead of stalling the run. A step that returns
104
+ `{ warn: '…' }` is recorded as a warning, and `t.mail` has `count()` and `all()`, with each message's `id` and
105
+ `headers` (for checks such as List-Unsubscribe on every email of a send).
67
106
  `t.jev()` waits for the page to settle and looks again when the page reloads under it. The crawl takes a link to a
68
107
  file (a PDF download) for what it is, not a page that answered 0, and a signed-out side skips the routes the list
69
108
  marks `auth`. Stopping the app stops what `app.start` left running in the background too, and `app.stop` runs only
@@ -80,7 +119,8 @@ The first release: on npm as `@ashishjain15491/tapcheck` (the CLI is still `tapc
80
119
  answer's status and skips refused ones; Mailpit and stub calls give up after 30 s or at the timeout;
81
120
  `t.mail.all({ limit })`; a form POST with `_method` is reached as that method.
82
121
  `browser.args` passes extra switches to the run's Chromium (an app on localhost whose sandboxed preview frames load
83
- its own files needs `--disable-features=LocalNetworkAccessChecks`). A side whose sign-in fails says so in the terminal, not only in the report.
122
+ its own files needs `--disable-features=LocalNetworkAccessChecks`). A side whose sign-in fails says so in the
123
+ terminal, not only in the report.
84
124
  Waiting for a page to settle is capped outside the page, so a page whose own timers never fire (one
85
125
  sandboxed by its CSP without `allow-scripts`, such as an email preview) can't hang the run.
86
126
  `t.page({ viewport: 'mobile' })` hands a flow a page at any of the config's viewports (the first one by default), so
package/README.md CHANGED
@@ -38,7 +38,8 @@ Jev parts are skipped and everything else runs.
38
38
 
39
39
  Pick one. Each runs the same CLI.
40
40
 
41
- **Claude Code or Codex plugin.** Three skills set tapcheck up for your app, run it and fix what it finds. In Claude
41
+ **Claude Code or Codex plugin.** Four skills set tapcheck up for your app, run it, fix what it finds and verify a
42
+ release or a pull request item by item. In Claude
42
43
  Code:
43
44
 
44
45
  ```
@@ -63,7 +64,7 @@ npm install --save-dev tapcheck@npm:@ashishjain15491/tapcheck
63
64
  npx playwright install chromium # once
64
65
  ```
65
66
 
66
- Or run it without installing: `npx @ashishjain15491/tapcheck@0.1.1`.
67
+ Or run it without installing: `npx @ashishjain15491/tapcheck@0.1.3`.
67
68
 
68
69
  **GitHub Action** and **Docker**: see [Run it](#3-run-it) below.
69
70
 
@@ -144,7 +145,7 @@ uploads the run folder and fails the step when a check fails; inputs are in [act
144
145
  - uses: actions/checkout@v4
145
146
  with: { fetch-depth: 0 } # for changed: base
146
147
  # …install your app's language, dependencies and a test database…
147
- - uses: ashishjain15491/tapcheck@v0.1.1
148
+ - uses: ashishjain15491/tapcheck@v0.1.3
148
149
  with:
149
150
  changed: base # optional: only what the pull request changed
150
151
  env:
@@ -161,8 +162,8 @@ git clone https://github.com/ashishjain15491/tapcheck && docker build -t tapchec
161
162
  docker run --rm --ipc=host -e TYPESAFE_API_KEY -v "$PWD:/work" -w /work tapcheck
162
163
  ```
163
164
 
164
- Options are environment variables (`ONLY`, `SKIP`, `CHANGED`, `PARALLEL=4` for flows at once, `LIST=1` to list the
165
- parts); the full list is in [CONFIG.md](skills/tapcheck-setup/references/CONFIG.md#environment-variables-for-a-run).
165
+ Options are environment variables (`ONLY`, `SKIP`, `CHANGED`, `PARALLEL=4` for flows at once, `MARK=1` for marked
166
+ screenshots, `LIST=1` to list the parts); the full list is in [CONFIG.md](skills/tapcheck-setup/references/CONFIG.md#environment-variables-for-a-run).
166
167
 
167
168
  ## Output
168
169
 
package/dist/auth.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type { Config, Side } from './config.ts';
2
2
  /** RFC 6238 time-based one-time code (SHA-1, 30 s, 6 digits) from a base32 secret. */
3
3
  export declare function totp(secret: string, at?: number): string;
4
+ /** Signed in at `u`: back on the side's own site (not on a Google, Discord or other sign-in provider's page) and on no sign-in path. */
5
+ export declare const off: (cfg: Config, side: Side, u: string) => boolean;
4
6
  /** The side's saved session file, signing in first when needed; undefined for a side that doesn't sign in. */
5
7
  export declare function signIn(cfg: Config, side: Side): Promise<string | undefined>;
package/dist/auth.js CHANGED
@@ -30,10 +30,14 @@ export function totp(secret, at = Date.now()) {
30
30
  async function field(page, key) {
31
31
  if (/^[#.[]|[\s=>]/.test(key))
32
32
  return page.locator(key).first();
33
- const byName = page.locator(`[name="${key.replace(/"/g, '\\"')}"]`);
33
+ const byName = page.locator(`[name="${key.replace(/[\\"]/g, '\\$&')}"]`);
34
34
  return (await byName.count()) ? byName.first() : page.getByLabel(key, { exact: false }).first();
35
35
  }
36
- const off = (cfg, u) => !cfg.loginPaths.test(new URL(u).pathname);
36
+ /** Signed in at `u`: back on the side's own site (not on a Google, Discord or other sign-in provider's page) and on no sign-in path. */
37
+ export const off = (cfg, side, u) => {
38
+ const url = new URL(u);
39
+ return url.origin === new URL(side.baseUrl).origin && !cfg.loginPaths.test(url.pathname);
40
+ };
37
41
  /** The side's saved session file, signing in first when needed; undefined for a side that doesn't sign in. */
38
42
  export async function signIn(cfg, side) {
39
43
  const l = side.login;
@@ -64,7 +68,9 @@ export async function signIn(cfg, side) {
64
68
  const page = await ctx.newPage();
65
69
  await page.goto(at(l.manual));
66
70
  console.log(`Sign in as ${side.name} in the browser window. Waiting up to 10 minutes…`);
67
- await page.waitForURL((u) => off(cfg, u.href), { timeout: 600_000 });
71
+ await page.waitForURL((u) => off(cfg, side, u.href), { timeout: 600_000 });
72
+ if (side.signedIn)
73
+ await page.locator(side.signedIn).first().waitFor({ state: 'attached', timeout: 600_000 });
68
74
  await page.waitForLoadState('networkidle').catch(() => { });
69
75
  await ctx.storageState({ path: file });
70
76
  await browser.close();
@@ -81,12 +87,12 @@ export async function signIn(cfg, side) {
81
87
  const submit = () => page.locator(f.submit ?? 'button[type=submit], input[type=submit]').first().click();
82
88
  await submit();
83
89
  await page.waitForLoadState('networkidle', { timeout: 15_000 }).catch(() => { });
84
- if (f.totp && !off(cfg, page.url())) {
90
+ if (f.totp && !off(cfg, side, page.url())) {
85
91
  await (await field(page, f.totp.field)).fill(totp(f.totp.secret));
86
92
  await submit();
87
93
  }
88
- await page.waitForURL((u) => off(cfg, u.href), { timeout: 30_000 }).catch(() => { });
89
- if (!off(cfg, page.url())) {
94
+ await page.waitForURL((u) => off(cfg, side, u.href), { timeout: 30_000 }).catch(() => { });
95
+ if (!off(cfg, side, page.url())) {
90
96
  const shot = `${cfg.out}/login-${side.name}-failed.png`;
91
97
  await page.screenshot({ path: shot }).catch(() => { });
92
98
  throw new Error(`Signing in as ${side.name} left the browser on ${page.url()} (see ${shot}). Check sides.${side.name}.login.form.`);
package/dist/browser.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type Browser, type BrowserContext, type BrowserContextOptions, type Page } from 'playwright';
1
+ import { type Browser, type BrowserContext, type BrowserContextOptions, type Locator, type Page } from 'playwright';
2
2
  import type { Config, Screen, Side } from './config.ts';
3
3
  import type { Finding } from './report.ts';
4
4
  export type Viewport = Config['viewports'][number];
@@ -38,6 +38,7 @@ export type Run = {
38
38
  step?: string;
39
39
  reached?: Reach[];
40
40
  prefix?: string;
41
+ scoped?: boolean;
41
42
  };
42
43
  /** One thing a part touched: "GET /orders", "dialog <name>", "table <headers>: sort". */
43
44
  export type Reach = {
@@ -83,12 +84,6 @@ export declare function routedMethod(q: {
83
84
  export declare const abs: (r: Run, path: string) => string;
84
85
  export declare const host: (u: string) => string;
85
86
  export declare const slug: (s: string) => string;
86
- /**
87
- * A context at this viewport: signed in with the side's session unless auth is false. Every suite and flow gets its
88
- * contexts here, so two things hold for all of them: each answered request to the side's own host is filed for the
89
- * coverage map, and with RECORD=1 the context records a video per page (<side dir>/videos/) and a Playwright trace
90
- * (<side dir>/traces/), written when the context closes.
91
- */
92
87
  export declare function context(r: Run, vp: Viewport, auth?: boolean, bypassCSP?: boolean, more?: BrowserContextOptions): Promise<BrowserContext>;
93
88
  /** Console errors and uncaught page errors, collected from now on. */
94
89
  export declare function watch(page: Page): string[];
@@ -102,6 +97,16 @@ export declare class SessionExpired extends Error {
102
97
  }
103
98
  /** Being sent to a sign-in page on a side that signs in means the session is gone: stop rather than audit the login page. */
104
99
  export declare function guard(r: Run, requested: string, landed: string): void;
100
+ /** guard, and on a signed-in page also the side's `signedIn` selector: an app that shows its sign-in form in place, at
101
+ * the same address (a hash-routed app), sends no one anywhere, so only what is on the page tells. */
102
+ export declare function signedIn(r: Run, page: Page, requested: string): Promise<void>;
103
+ /** A hash route (`/#scanner`, `/#/orders`): an app that routes in the fragment shows a different screen for each. */
104
+ export declare const hashRoute: (path: string) => boolean;
105
+ /** Where the page is, as a path: the hash too when `path` (what was asked for) is a hash route. */
106
+ export declare function here(url: string, path: string): string;
107
+ /** page.goto as a document load. Going to another hash of the page that's open only changes the fragment: the browser
108
+ * sends nothing, so there is no response (status 0) and the app may not start afresh. Leave the page first. */
109
+ export declare function load(page: Page, url: string, opts?: Parameters<Page['goto']>[1]): Promise<import("playwright").Response | null>;
105
110
  /** Opens a page of the app and waits for it to settle. A load that fails (a timeout on a busy app, a navigation
106
111
  * aborted or cut short by another) is tried once more before the error counts; a download is not a page and isn't. */
107
112
  export declare function open(r: Run, page: Page, path: string): Promise<import("playwright").Response | null>;
@@ -141,3 +146,26 @@ export declare function facts(page: Page): Promise<{
141
146
  smallTargets: string[];
142
147
  h1: number;
143
148
  }>;
149
+ export type MarkKind = 'bug' | 'pass' | 'setting' | 'question';
150
+ /** One thing a marked screenshot points at: a selector or a Playwright locator (each element it matches gets a box), or a plain box in viewport pixels. */
151
+ export type Mark = {
152
+ target: string | Locator | {
153
+ x: number;
154
+ y: number;
155
+ width: number;
156
+ height: number;
157
+ };
158
+ note?: string;
159
+ kind?: MarkKind;
160
+ };
161
+ export declare function marked(r: Run, page: Page, label: string, banner: {
162
+ status: Finding['status'];
163
+ title: string;
164
+ detail?: string;
165
+ }, marks?: Mark[]): Promise<string | undefined>;
166
+ /**
167
+ * With marks on, each fail and warning of `list` that has a screenshot but no marked one (what Jev judged, a failed flow
168
+ * step) gets a copy of it with the banner alone, put first in its evidence. Jev says what is wrong, not where, so no
169
+ * box is drawn.
170
+ */
171
+ export declare function banners(r: Run, list: Finding[]): Promise<void>;
package/dist/browser.js CHANGED
@@ -1,8 +1,9 @@
1
1
  /*
2
2
  * The browser side every suite shares: one Chromium, a context per viewport (signed in with the side's saved session, or
3
- * not), page settling, the facts code can measure on a page, screenshot slices, and the Run each suite is handed.
3
+ * not), page settling, the facts code can measure on a page, screenshot slices, marked screenshots, and the Run each
4
+ * suite is handed.
4
5
  */
5
- import { mkdirSync } from 'node:fs';
6
+ import { mkdirSync, readFileSync } from 'node:fs';
6
7
  import { chromium } from 'playwright';
7
8
  /** Every recording of the run (RECORD=1), for the report. */
8
9
  export const recordings = [];
@@ -81,10 +82,20 @@ export const slug = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/
81
82
  * coverage map, and with RECORD=1 the context records a video per page (<side dir>/videos/) and a Playwright trace
82
83
  * (<side dir>/traces/), written when the context closes.
83
84
  */
85
+ /** The contexts that carry the side's session (and still have it). */
86
+ const authed = new WeakSet();
84
87
  export async function context(r, vp, auth = true, bypassCSP = false, more = {}) {
85
88
  const record = process.env.RECORD === '1';
86
89
  const ctx = await (await launch()).newContext({ ...(auth && r.auth ? { storageState: r.auth } : {}), viewport: { width: vp.width, height: vp.height },
87
90
  deviceScaleFactor: 1, isMobile: vp.mobile, hasTouch: vp.mobile, bypassCSP, ...(record ? { recordVideo: { dir: `${r.dir}/videos` } } : {}), ...more });
91
+ if (auth && r.auth) {
92
+ authed.add(ctx);
93
+ // Sessions whose tokens rotate (Supabase, Auth0, Cognito) are good only in their latest copy: keep it for the next
94
+ // context and the next run, unless this one found the session gone.
95
+ const close = ctx.close.bind(ctx);
96
+ ctx.close = async (...a) => { if (authed.delete(ctx))
97
+ await ctx.storageState({ path: r.auth }).catch(() => { }); return close(...a); };
98
+ }
88
99
  const own = host(r.side.baseUrl);
89
100
  // Reached: a request to the app itself that it didn't refuse (401, 403, 405) or not find (404). Page assets aside.
90
101
  ctx.on('response', (res) => {
@@ -146,20 +157,50 @@ export async function settle(page) {
146
157
  }
147
158
  export class SessionExpired extends Error {
148
159
  }
160
+ // LOGIN=1 only does something on a manual side; form and command sides sign in afresh on every run.
161
+ const again = (r) => ('manual' in r.side.login ? 'run again with LOGIN=1' : 'it ended during the run, or this user may not open that page');
149
162
  /** Being sent to a sign-in page on a side that signs in means the session is gone: stop rather than audit the login page. */
150
163
  export function guard(r, requested, landed) {
151
164
  if ('none' in r.side.login)
152
165
  return;
153
166
  if (r.cfg.loginPaths.test(new URL(landed).pathname) && !r.cfg.loginPaths.test(requested.split('?')[0])) {
154
- // LOGIN=1 only does something on a manual side; form and command sides sign in afresh on every run.
155
- const hint = 'manual' in r.side.login ? 'run again with LOGIN=1' : 'it ended during the run, or this user may not open that page';
156
- throw new SessionExpired(`Sent to sign in at ${landed}: the ${r.side.name} session has expired (${hint}).`);
167
+ throw new SessionExpired(`Sent to sign in at ${landed}: the ${r.side.name} session has expired (${again(r)}).`);
157
168
  }
158
169
  }
170
+ /** guard, and on a signed-in page also the side's `signedIn` selector: an app that shows its sign-in form in place, at
171
+ * the same address (a hash-routed app), sends no one anywhere, so only what is on the page tells. */
172
+ export async function signedIn(r, page, requested) {
173
+ if (!authed.has(page.context()))
174
+ return guard(r, requested, page.url());
175
+ try {
176
+ guard(r, requested, page.url());
177
+ if (r.side.signedIn && !(await page.locator(r.side.signedIn).first().waitFor({ state: 'attached', timeout: 5000 }).then(() => true, () => false))) {
178
+ throw new SessionExpired(`${requested} has no ${r.side.signedIn} on it: the ${r.side.name} session has expired (${again(r)}).`);
179
+ }
180
+ }
181
+ catch (e) {
182
+ authed.delete(page.context()); // not saved over the last good copy
183
+ throw e;
184
+ }
185
+ }
186
+ /** A hash route (`/#scanner`, `/#/orders`): an app that routes in the fragment shows a different screen for each. */
187
+ export const hashRoute = (path) => /#[!/]?[A-Za-z]/.test(path);
188
+ /** Where the page is, as a path: the hash too when `path` (what was asked for) is a hash route. */
189
+ export function here(url, path) {
190
+ const u = new URL(url);
191
+ return u.pathname + (hashRoute(path) ? u.hash : '');
192
+ }
193
+ /** page.goto as a document load. Going to another hash of the page that's open only changes the fragment: the browser
194
+ * sends nothing, so there is no response (status 0) and the app may not start afresh. Leave the page first. */
195
+ export async function load(page, url, opts = { waitUntil: 'domcontentloaded' }) {
196
+ if (url.includes('#') && page.url().split('#')[0] === url.split('#')[0])
197
+ await page.goto('about:blank');
198
+ return page.goto(url, opts);
199
+ }
159
200
  /** Opens a page of the app and waits for it to settle. A load that fails (a timeout on a busy app, a navigation
160
201
  * aborted or cut short by another) is tried once more before the error counts; a download is not a page and isn't. */
161
202
  export async function open(r, page, path) {
162
- const go = () => page.goto(abs(r, path), { waitUntil: 'domcontentloaded' });
203
+ const go = () => load(page, abs(r, path));
163
204
  const res = await go().catch(async (e) => {
164
205
  if (/Download is starting/.test(e.message))
165
206
  throw e;
@@ -167,7 +208,7 @@ export async function open(r, page, path) {
167
208
  return go();
168
209
  });
169
210
  await settle(page);
170
- guard(r, path, page.url());
211
+ await signedIn(r, page, path);
171
212
  return res;
172
213
  }
173
214
  /** A screen's path: given directly, or the first link on `from` whose path matches `link`. Null when no link matches. */
@@ -204,7 +245,8 @@ export async function facts(page) {
204
245
  const s = getComputedStyle(el);
205
246
  return r.width > 0 && r.height > 0 && s.visibility !== 'hidden' && s.display !== 'none' && Number(s.opacity) > 0 && !el.closest('[aria-hidden=true]');
206
247
  };
207
- const broken = [...document.images].filter((i) => visible(i) && i.complete && i.naturalWidth === 0).map((i) => i.currentSrc || i.src);
248
+ // Tagged for a marked screenshot (MARK=1), as the other measured elements are.
249
+ const broken = [...document.images].filter((i) => visible(i) && i.complete && i.naturalWidth === 0).map((i) => { i.setAttribute('data-tapcheck-mark-broken', 'does not load'); return i.currentSrc || i.src; });
208
250
  const controls = [...document.querySelectorAll('a[href], button, [role=button], input:not([type=hidden]), select, textarea, summary')]
209
251
  .filter(visible).slice(0, 250).map((el) => {
210
252
  const r = el.getBoundingClientRect();
@@ -235,3 +277,151 @@ export async function facts(page) {
235
277
  };
236
278
  });
237
279
  }
280
+ const KIND = { fail: 'bug', warn: 'question', info: 'setting', pass: 'pass' };
281
+ const COLOUR = { bug: '#dc2626', pass: '#15803d', setting: '#2563eb', question: '#b45309' };
282
+ const MAX_MARKS = 8; // boxes per screenshot; the banner says how many more there are
283
+ let shotNo = 0; // in every marked screenshot's name: a slug is cut at 48 characters, so two could share one
284
+ /**
285
+ * Runs in the page: a box, a numbered marker and a note per target, in a layer above everything. Markers and notes go
286
+ * where they cover no other marker or note (and, if they can, no other target). Returns how many targets weren't drawn.
287
+ */
288
+ function draw({ marks, max }) {
289
+ const vw = innerWidth, vh = innerHeight;
290
+ const root = document.createElement('div');
291
+ root.id = 'tapcheck-marks';
292
+ root.style.cssText = 'position:fixed;inset:0;width:auto;height:auto;margin:0;border:0;padding:0;background:none;overflow:hidden;z-index:2147483647;pointer-events:none;font:600 13px/1.3 system-ui,sans-serif;color:#fff;text-align:left';
293
+ document.documentElement.append(root);
294
+ // The top layer, or an open modal dialog would cover the marks; where there is no popover the z-index has to do.
295
+ try {
296
+ root.popover = 'manual';
297
+ root.showPopover();
298
+ }
299
+ catch {
300
+ root.removeAttribute('popover');
301
+ }
302
+ const add = (css, text) => { const d = document.createElement('div'); d.style.cssText = `position:absolute;box-sizing:border-box;${css}`; d.textContent = text; root.append(d); return d; };
303
+ const all = marks.flatMap((m, i) => (m.box ? [{ ...m.box, note: m.note ?? '' }] : [...document.querySelectorAll(`[data-tapcheck-m${i}]`)].map((el) => {
304
+ const b = el.getBoundingClientRect();
305
+ return { x: b.left, y: b.top, width: b.width, height: b.height, note: m.note ?? (m.attr && el.getAttribute(m.attr)) ?? '' };
306
+ })).map((b) => ({ ...b, colour: m.colour })));
307
+ const shown = all.filter((b) => b.width > 0 && b.height > 0 && b.x < vw && b.y < vh && b.x + b.width > 0 && b.y + b.height > 0).slice(0, max);
308
+ const labels = [];
309
+ const boxes = shown.map((b) => ({ x: b.x - 3, y: b.y - 3, w: b.width + 6, h: b.height + 6 }));
310
+ const hits = (a, b) => a.x < b.x + b.w + 2 && b.x < a.x + a.w + 2 && a.y < b.y + b.h + 2 && b.y < a.y + a.h + 2;
311
+ const inside = (v, size, limit) => Math.max(2, Math.min(v, limit - size - 2));
312
+ // The nearest clear spot: the wanted ones, then each moved down or up a step at a time; one clear of the other labels
313
+ // and the other targets, else of the other labels. A marker would rather cover a target than leave its box.
314
+ const place = (w, h, want, own, marker = false) => {
315
+ const steps = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6], others = boxes.filter((_, i) => i !== own);
316
+ const spots = steps.flatMap((k) => want.map(([x, y]) => ({ x: inside(x, w, vw), y: inside(y + k * (h + 3), h, vh), w, h, k }))).filter((s) => !labels.some((l) => hits(s, l)));
317
+ const clear = (s) => !others.some((b) => hits(s, b)), near = spots.filter((s) => s.k === 0);
318
+ const spot = near.find(clear) ?? (marker ? near[0] : undefined) ?? spots.find(clear) ?? spots[0]
319
+ ?? { x: inside(want[0][0], w, vw), y: inside(want[0][1], h, vh), w, h };
320
+ labels.push(spot);
321
+ return spot;
322
+ };
323
+ for (const b of shown) {
324
+ const l = Math.max(0, b.x - 3), t = Math.max(0, b.y - 3); // 3 px around the element, cut at the window's edge
325
+ add(`left:${l}px;top:${t}px;width:${Math.min(vw, b.x + b.width + 3) - l}px;height:${Math.min(vh, b.y + b.height + 3) - t}px;border:3px solid ${b.colour};border-radius:4px`, '');
326
+ }
327
+ // Every marker first, so each gets a spot by its box: on its top left corner, else another corner, else beside it.
328
+ for (const [i, b] of shown.entries()) {
329
+ const mid = b.y + b.height / 2 - 12;
330
+ const m = place(24, 24, [[b.x - 14, b.y - 14], [b.x + b.width - 10, b.y - 14], [b.x - 14, b.y + b.height - 10], [b.x + b.width - 10, b.y + b.height - 10], [b.x - 28, mid], [b.x + b.width + 4, mid]], i, true);
331
+ add(`left:${m.x}px;top:${m.y}px;width:24px;height:24px;border-radius:50%;background:${b.colour};border:2px solid #fff;display:grid;place-items:center;font-size:12px`, String(i + 1));
332
+ }
333
+ for (const [i, b] of shown.entries()) {
334
+ if (!b.note)
335
+ continue;
336
+ // The note: right of the box (or of a marker beside it), left of it, at the right end inside it (a row as wide as the
337
+ // window), under it or above it.
338
+ const n = add(`max-width:300px;padding:3px 8px;border-radius:3px;background:${b.colour};border:1px solid #fff`, `${i + 1} ${b.note.slice(0, 90)}`);
339
+ const s = n.getBoundingClientRect();
340
+ const at = place(s.width, s.height, [[b.x + b.width + 8, b.y], [b.x + b.width + 32, b.y], [b.x - 8 - s.width, b.y], [b.x - 32 - s.width, b.y], [b.x + b.width - s.width - 6, b.y], [b.x, b.y + b.height + 6], [b.x, b.y - 6 - s.height]]
341
+ .filter(([x], k) => k > 4 || (x >= 0 && x + s.width <= vw && (k < 4 || b.width > 2 * s.width))), i);
342
+ n.style.left = `${at.x}px`;
343
+ n.style.top = `${at.y}px`;
344
+ }
345
+ return all.length - shown.length; // past the cap, or not on this screen
346
+ }
347
+ let blank; // where a screenshot gets its banner: a page of its own, so the app's own page is never covered
348
+ /** `png` with a banner above it, in the status's colour, saying the check and its detail; written to `file`. */
349
+ async function frame(png, file, banner, more = 0) {
350
+ if (!blank || blank.isClosed())
351
+ blank = await (await (await launch()).newContext({ deviceScaleFactor: 1 })).newPage();
352
+ const esc = (t) => t.replace(/[&<>]/g, (c) => `&#${c.charCodeAt(0)};`);
353
+ const title = `${banner.status.toUpperCase()}: ${banner.title}`.slice(0, 160) + (more ? ` (+${more} more)` : '');
354
+ const detail = (banner.detail ?? '').slice(0, 260);
355
+ await blank.setContent(`<body style="margin:0;background:#fff"><div id="tapcheck-banner" style="padding:10px 16px;background:${COLOUR[KIND[banner.status]]};color:#fff;font:600 18px/1.3 system-ui,sans-serif">${esc(title)}${detail ? `<div style="font:400 14px/1.35 system-ui,sans-serif;margin-top:2px">${esc(detail)}</div>` : ''}</div><img style="display:block" src="data:image/png;base64,${png.toString('base64')}">`);
356
+ const width = await blank.evaluate(async () => { const i = document.images[0]; await i.decode(); return i.naturalWidth; });
357
+ await blank.setViewportSize({ width, height: 200 });
358
+ await blank.screenshot({ path: file, fullPage: true });
359
+ }
360
+ /**
361
+ * A marked screenshot, <run dir>/shots/marked-<n>-<name>.png: the page as it is with a box, a numbered marker and a note
362
+ * on each target (at most 8; the banner counts the rest), under a banner in the status's colour (red fail, amber warn,
363
+ * green pass, blue info) saying the check and its detail. The first target is scrolled into view. The overlay is drawn
364
+ * in the page and taken out again, with the scroll position put back. Undefined when it couldn't be taken: a marked
365
+ * screenshot is an extra, and never fails the check it shows.
366
+ */
367
+ const name = (r, label) => `${r.dir}/shots/marked-${String(++shotNo).padStart(3, '0')}-${slug(label)}.png`;
368
+ export async function marked(r, page, label, banner, marks = []) {
369
+ const file = name(r, label);
370
+ let at;
371
+ try {
372
+ mkdirSync(`${r.dir}/shots`, { recursive: true });
373
+ const list = [];
374
+ for (const [i, m] of marks.entries()) {
375
+ const t = m.target, box = typeof t !== 'string' && 'x' in t ? t : undefined;
376
+ if (!box)
377
+ await (typeof t === 'string' ? page.locator(t) : t).evaluateAll((els, a) => els.forEach((el) => el.setAttribute(a, '')), `data-tapcheck-m${i}`).catch(() => { });
378
+ // An element a suite tagged while measuring carries its own note in the tag.
379
+ list.push({ box, note: m.note, attr: typeof t === 'string' ? /^\[(data-tapcheck-mark-[a-z]+)\]$/.exec(t)?.[1] : undefined, colour: COLOUR[m.kind ?? KIND[banner.status]] });
380
+ }
381
+ at = await page.evaluate((n) => {
382
+ const at = [scrollX, scrollY];
383
+ for (let i = 0; i < n; i++) {
384
+ const el = document.querySelector(`[data-tapcheck-m${i}]`);
385
+ if (!el)
386
+ continue;
387
+ const b = el.getBoundingClientRect();
388
+ if (b.top < 0 || b.left < 0 || b.bottom > innerHeight || b.right > innerWidth)
389
+ el.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'instant' });
390
+ break;
391
+ }
392
+ return at;
393
+ }, marks.length);
394
+ const more = await page.evaluate(draw, { marks: list, max: MAX_MARKS });
395
+ const png = await page.screenshot();
396
+ await frame(png, file, banner, more);
397
+ return file;
398
+ }
399
+ catch {
400
+ return undefined;
401
+ }
402
+ finally {
403
+ await page.evaluate(({ n, at }) => {
404
+ document.getElementById('tapcheck-marks')?.remove();
405
+ for (let i = 0; i < n; i++)
406
+ document.querySelectorAll(`[data-tapcheck-m${i}]`).forEach((el) => el.removeAttribute(`data-tapcheck-m${i}`));
407
+ if (at)
408
+ scrollTo(at[0], at[1]);
409
+ }, { n: marks.length, at }).catch(() => { });
410
+ }
411
+ }
412
+ /**
413
+ * With marks on, each fail and warning of `list` that has a screenshot but no marked one (what Jev judged, a failed flow
414
+ * step) gets a copy of it with the banner alone, put first in its evidence. Jev says what is wrong, not where, so no
415
+ * box is drawn.
416
+ */
417
+ export async function banners(r, list) {
418
+ for (const f of list.filter((f) => (f.status === 'fail' || f.status === 'warn') && /\.png$/.test(f.evidence?.[0] ?? '') && !f.evidence[0].includes('/shots/marked-'))) {
419
+ const file = name(r, `${f.suite} ${f.where} ${f.check}`);
420
+ try {
421
+ mkdirSync(`${r.dir}/shots`, { recursive: true });
422
+ await frame(readFileSync(f.evidence[0]), file, { status: f.status, title: f.check, detail: [f.where, f.detail].filter(Boolean).join(' · ') });
423
+ f.evidence = [file, ...f.evidence]; // a new list: findings of one look share theirs
424
+ }
425
+ catch { /* the screenshot is gone or isn't one: the finding stands without a banner */ }
426
+ }
427
+ }
package/dist/cli.js CHANGED
@@ -6,7 +6,8 @@
6
6
  * side, and jev (ux, usability) or measured (crawl, contract, security, a11y, interact, audit). Two more kinds of part:
7
7
  * code the project's own gates (`gates:`) and the route sign-in check (`routes:`); tags code, measured. It has
8
8
  * no side: a run of only `code` starts no app and no browser.
9
- * flow-<name> each custom flow (`flows:`, see src/flow.ts) on its side; tags flow, its side, measured.
9
+ * flow-<name> each custom flow (`flows:`, see src/flow.ts) on its side; tags flow, its side, measured, and verify
10
+ * when it checks a release item (`item`): the report then opens with "Release verification".
10
11
  * With `stub:` in tapcheck.yml, a stub server (src/stub.ts) stands in for the outside services the app calls; it starts
11
12
  * before the app, and its address is TAPCHECK_STUB_URL for app.start, the gates and tapcheck.yml itself (with `stub.dns`
12
13
  * it answers DNS too, at TAPCHECK_DNS).
@@ -29,6 +30,9 @@
29
30
  * actions; START_DELAY=10 counts down that many seconds before the first one
30
31
  * RECORD=1 tapcheck a video and a Playwright trace of every browser context, per side under videos/ and
31
32
  * traces/, linked from the report (open a trace with npx playwright show-trace <file>)
33
+ * MARK=1 tapcheck marked screenshots (default `marks` in tapcheck.yml): a fail's or warning's evidence opens
34
+ * with the screen as it was, a banner saying the check, and a box and a note on each element
35
+ * the check knows; what Jev judged gets the banner alone
32
36
  * COVERAGE=1 tapcheck no run: merge the hits.json of every run so far into COVERAGE.md (coverage.file): each
33
37
  * route of `routes:` with the part that reached it or GAP, and the dialogs and tables seen
34
38
  * LOGIN=1 tapcheck sign in again by hand on manual sides
@@ -50,12 +54,12 @@ import { dirname, resolve } from 'node:path';
50
54
  import { CHANGE_KEYS, isLocal, load, SUITES } from './config.js';
51
55
  import { build, changedParts, findingSuite, list, mark, pool, resetDue, select, snapshot, withNeeds } from './parts.js';
52
56
  import { signIn } from './auth.js';
53
- import { closeBrowser, countdown, launch, recordings, SessionExpired, startDelay } from './browser.js';
57
+ import { banners, closeBrowser, countdown, launch, recordings, SessionExpired, startDelay } from './browser.js';
54
58
  import { coverage, hits } from './coverage.js';
55
59
  import { routes } from './routes.js';
56
60
  import * as jev from './jev.js';
57
61
  import { loadFlows, runFlow } from './flow.js';
58
- import { findings, record, write } from './report.js';
62
+ import { expected, findings, record, write } from './report.js';
59
63
  import { start as startStub } from './stub.js';
60
64
  import * as code from './suites/code.js';
61
65
  import * as crawl from './suites/crawl.js';
@@ -152,7 +156,7 @@ if (!chosen.length) {
152
156
  process.exit(0);
153
157
  }
154
158
  console.log(`Running: ${chosen.map((p) => p.name).join(', ')}`);
155
- jev.setup(cfg.jev);
159
+ jev.setup({ ...cfg.jev, context: cfg.context });
156
160
  // Why the Jev parts are skipped, or '' when they run. Once the budget is reached it says so, and the rest are skipped too.
157
161
  let jevOff = jev.whyOff();
158
162
  const jevParts = chosen.filter((p) => p.tags.includes('jev'));
@@ -161,6 +165,8 @@ const ran = []; // parts that ran, to the end or not
161
165
  const skipped = {}; // Jev parts left out, and why: neither passed nor failed
162
166
  const notRun = {}; // parts that couldn't run, and why: they count as failed
163
167
  const label = (p) => (p.suite === 'flow' ? p.name : p.suite);
168
+ /** A verify flow's release item, for the findings the run itself records about that part. */
169
+ const itemOf = (p) => { const item = flows.find((f) => f.part === p.name)?.item; return item ? { item } : {}; };
164
170
  /** Runs one part; what it throws becomes a failing finding of its own and is returned. */
165
171
  async function runPart(p, rec, fn, together = false) {
166
172
  const t0 = Date.now();
@@ -175,7 +181,7 @@ async function runPart(p, rec, fn, together = false) {
175
181
  catch (e) {
176
182
  const msg = e.message;
177
183
  console.log(`${end}stopped: ${msg}`);
178
- rec({ suite: findingSuite(p), where: 'suite', check: 'suite ran to the end', status: 'fail', detail: msg.slice(0, 300) });
184
+ rec({ suite: findingSuite(p), where: 'suite', check: 'suite ran to the end', status: 'fail', detail: msg.slice(0, 300), ...itemOf(p) });
179
185
  return e;
180
186
  }
181
187
  }
@@ -218,7 +224,7 @@ try {
218
224
  await countdown();
219
225
  const codePart = chosen.find((p) => p.suite === 'code');
220
226
  if (codePart) {
221
- const rec = (f) => record({ ...f, side: '' });
227
+ const rec = (f) => record(expected({ ...f, side: '' }, cfg.expect));
222
228
  console.log(`\ncode: ${cfg.gates.length} gate(s)${cfg.routes ? ', routes' : ''}`);
223
229
  await runPart(codePart, rec, () => code.run(cfg, dir, rec));
224
230
  }
@@ -230,7 +236,8 @@ try {
230
236
  mkdirSync(sideDir, { recursive: true });
231
237
  console.log(`\n${side.name} at ${side.baseUrl}: ${parts.map(label).join(', ')}`);
232
238
  // reached: one list, so the copies the flows running together get (each its own part and step) share it
233
- const r = { cfg, side, dir: sideDir, record: (f) => record({ ...f, side: side.name }), crawl: { pages: [], hits: [], done: false }, reached: [] };
239
+ const r = { cfg, side, dir: sideDir, record: (f) => record(expected({ ...f, side: side.name }, cfg.expect)), crawl: { pages: [], hits: [], done: false }, reached: [],
240
+ scoped: !!process.env.ONLY || !['', '0'].includes(process.env.CHANGED ?? '') };
234
241
  try {
235
242
  r.auth = await signIn(cfg, side);
236
243
  }
@@ -249,7 +256,11 @@ try {
249
256
  return;
250
257
  }
251
258
  const flow = flows.find((f) => f.part === p.name);
259
+ const from = findings.length;
252
260
  const e = await runPart(p, rp.record, () => (flow ? runFlow(flow, rp, stub?.url) : RUN[p.suite](rp)), together);
261
+ // MARK=1: what this part found with a plain screenshot (Jev's judgments, a failed step) gets the banner on it.
262
+ if (cfg.marks)
263
+ await banners(rp, findings.slice(from).filter((f) => f.suite === findingSuite(p) && f.side === p.side)).catch(() => { });
253
264
  if (e instanceof jev.BudgetReached)
254
265
  jevOff = 'Jev budget reached';
255
266
  if (e instanceof SessionExpired)
@@ -293,7 +304,7 @@ finally {
293
304
  const skip = skipped[p.name];
294
305
  const hint = skip && !/budget/.test(skip) ? ' To run it, set TYPESAFE_API_KEY in the environment or in .env here, without JEV=off.'
295
306
  : skip ? ' Raise JEV_BUDGET (or jev.budget) to let it finish.' : '';
296
- record({ suite: findingSuite(p), side: p.side, where: p.name, check: 'part ran', status: skip ? 'info' : 'fail',
307
+ record({ ...itemOf(p), suite: findingSuite(p), side: p.side, where: p.name, check: 'part ran', status: skip ? 'info' : 'fail',
297
308
  detail: `${skip ? `skipped (${skip})` : `not run (${notRun[p.name] ?? 'the run stopped before it'})`}.${hint}` });
298
309
  }
299
310
  const { bySuite, fails } = write(dir, { base: cfg.baseUrl, started, note, recordings });
package/dist/config.d.ts CHANGED
@@ -77,6 +77,7 @@ export type Side = {
77
77
  screens: Screen[];
78
78
  tasks: Task[];
79
79
  csrf?: Csrf;
80
+ signedIn?: string;
80
81
  };
81
82
  export type Config = {
82
83
  root: string;
@@ -123,6 +124,11 @@ export type Config = {
123
124
  }[];
124
125
  out: string;
125
126
  audience: string;
127
+ context?: string;
128
+ expect: {
129
+ match: RegExp;
130
+ why: string;
131
+ }[];
126
132
  jev: {
127
133
  budget: number;
128
134
  headers: Record<string, string>;
@@ -157,6 +163,7 @@ export type Config = {
157
163
  browser: {
158
164
  args: string[];
159
165
  };
166
+ marks: boolean;
160
167
  };
161
168
  /** Replaces $NAME and ${NAME} in every string with the environment's value; a missing variable is an error. */
162
169
  export declare function expand(v: unknown, at?: string): any;